# 用会话管理登录
from flask import Flask,session
from cheker import check_logged_in


app = Flask(__name__)


@app.route('/')
def hell0() -> str:
    return 'welcome to a simple weapp'


@app.route('/page1')
@check_logged_in

def page1() -> str:
    return 'this is page1'


@app.route('/page2')
@check_logged_in

def page2() -> str:
    return 'this is page2'


@app.route('/page3')

@check_logged_in
def page3() -> str:
    return 'this is page3'

@app.route('/login')
def do_login()->str:
    session['logged_in']=True
    return 'you r now logged in'

@app.route('/logout')
def do_logout()->str:
    session.pop('logged_in')
    return 'you r now logged out'
'''
@app.route('/status')
def check_status()->str:
    if 'logged_in' in session:
        'you r now logged in'
    return 'you r now logged out'
'''
app.secret_key='123woshibyl!'

if __name__ == '__main__':
    app.run(debug=True)